#include "clkDraw.h"

void drawAABB(V3DF a_min, V3DF a_max, float a_height, clkColor a_color)
{
	clkCore* core = clkCore::getInstance();

	float h = a_height;
	a_min.y = h; a_max.y = h;
	V3DF omin(a_min.x,h,a_max.z);
	V3DF omax(a_max.x,h,a_min.z);

	core->drawLine(a_min,omax,a_color);
	core->drawLine(omax,a_max,a_color);
	core->drawLine(a_max,omin,a_color);
	core->drawLine(omin,a_min,a_color);
}

void drawGrid(V3DF a_dimension, int a_unit, clkColor a_color)
{
	clkCore* core = clkCore::getInstance();

	if(a_unit <= 0)
		a_unit = 1;

	core->drawLine(
		(a_dimension/-2.0f)*V3DF(1,0,0),
		(a_dimension/2.0f)*V3DF(1,0,0),a_color);

	core->drawLine(
		(a_dimension/-2.0f)*V3DF(0,0,1),
		(a_dimension/2.0f)*V3DF(0,0,1),a_color);

	int xsize = (int)(a_dimension.x/2.0f);
	for(int i=-xsize;i<xsize+a_unit;i+=a_unit)
	{
		core->drawLine(
			V3DF((float)i,0,-a_dimension.z/2.0f),
			V3DF((float)i,0,a_dimension.z/2.0f),
			a_color);
	}

	int zsize = (int)(a_dimension.z/2.0f);
	for(int i=-zsize;i<zsize+a_unit;i+=a_unit)
	{
		core->drawLine(
			V3DF(-a_dimension.x/2.0f,0,(float)i),
			V3DF(a_dimension.x/2.0f,0,(float)i),
			a_color);
	}
}